package cn.czh.feignclient;

import cn.czh.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
//交给spring管理
@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    /**
     * 匿名内部类
     * @param throwable
     * @return
     */
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {

            @Override
            public User getById(Long id) {
                return new  User(-1L,"触发熔断","用户服务不可用,请稍后重试");
            }
        };
    }
}